<template>
    <div>
    <MineTitle/>
    <div class="account-phone">{{$store.state.login[this.index].account}}</div>
    <div class="phone-input">
            <input style="width: 240px;" type="password" placeholder="请输入密码" v-model="pwd" @input="lengthLimit">
        </div>
        <van-button class="register" @click="checkNewAccount" v-show="confirm" round block type="info" >登录</van-button>
    </div>
</template>
<script>
import MineTitle from "@/components/Mine/MineTitle.vue";
import { Toast } from "vant";
export default {
    props:["index"],
    data(){
        return{
            pwd:'',
            confirm:false,
        }
    },
    methods:{
        lengthLimit(){
            this.pwd=this.pwd.trim()
            // 当长度大于6
            if(this.pwd.trim().length===6){
                this.confirm=true
            }
        },
        checkNewAccount(){
            if(this.pwd==this.$store.state.login[this.index].password){
                let b = true
                Toast("登录成功")
                this.$store.commit("changeLoginstate",b)
                // this.$store.commit("changeLoginindex",this.index)
                this.$router.push({name:"mine"})
            }else{
                Toast("登录失败,请检查密码")
            }
        }

    },
    components: { MineTitle }
}
</script>

<style lang="scss" scoped>
 .account-phone{
            color:#333;
            width: 150px;
            margin: 20px auto;
            font-size: 24px;
            line-height: 30px;
        }
.phone-input{
    width: 230px;
            // height: 40px;
            display: flex;
            margin: 0 auto;
            background: rgba(240,240,240,1);
            // background-color: #fff;
            border: #fff 1px solid;
            padding: 10px 0 10px 10px;
            border-radius: 12px;
            line-height: 20px;
            input{
              background: rgba(240,240,240,1);
                width: 140px;
                height: 20px;
                padding: 0 10px;
                box-sizing: border-box;
                caret-color: var(--yellow);
                border: none;
            }
            input::-webkit-input-placeholder{
                color: #cfcfcf;
            }
            input::-moz-placeholder{   /* Mozilla Firefox 19+ */
                color: #cfcfcf;
            }
            input:-moz-placeholder{    /* Mozilla Firefox 4 to 18 */
                color: #cfcfcf;
            }
            input:-ms-input-placeholder{  /* Internet Explorer 10-11 */
                color: #cfcfcf;
            }
        }
        .register{
            width: 80%;
            margin: 0 auto;
            margin-top: 50px;
        }
</style>